<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function coloring() {
      let r = Math.floor(Math.random() * 255);
      let g = Math.floor(Math.random() * 255);
      let b = Math.floor(Math.random() * 255);
      document.body.style.background = `rgb(${r}, ${g}, ${b})`;
    }

    function throttle(func, delay) {
      let timer;
      return function () {
        let context = this;
        let args = arguments;
        if (timer) {
          return;
        }
        timer = setTimeout(function () {
          func.apply(context, args);
          timer = null;
        }, delay)
      }
    }

    window.addEventListener('resize', throttle(coloring, 1000))
  </script>
</body>

</html>